<template>
  <div class="interaction-start">
    <div class="container">
      <div class="box-left">
        <div class="section">
          <div class="case-tip">
            <div class="case-tipName">{{cases.resourceCaseName}}</div>
            <div class="sm-group">
              <el-button type="text" size="mini" icon="el-icon-s-custom">{{cases.resourceGroupName}}</el-button>
              <el-button type="text" size="mini" icon="el-icon-s-grid">{{cases.nodeNum}}个环节</el-button>
            </div>
          </div>
          <!--<div class="train-info">-->
          <!--当前得分：87 排名：第五名-->
          <!--</div>-->
          <div class="case-con">{{cases.caseRequestEn}}</div>
        </div>
        <div class="section">
          <div class="case-tip">实训小组</div>
          <div class="list-box">
            <ul>
              <li v-for="(item, index) in scores.groupIndex" :key="index" class="cursor" @click="groupScoreDetail(item.caseScoreId)">
                <el-button type="text" size="mini" icon="el-icon-s-custom">{{item.stuGroupName}}</el-button>
                <span class="right-arrow">{{item.totalScore}}分<i class="el-icon-arrow-right"></i></span>
              </li>
            </ul>
          </div>
        </div>
      </div>
      <div class="box-right">
        <!-- 评分详情 -->
        <div class="score-box" v-for="(item, index) in scoreDetail" :key="index">
          <div class="score-key">{{item.evaluateItem}}</div>
          <el-tooltip class="score-value" :content="item.evaluateItemRemark" placement="top">
            <div>
              {{item.evaluateItemScore}}分
              <i class="el-icon-success"></i>
            </div>
          </el-tooltip>
        </div>
        <el-button type="primary" class="inter-btn" @click="viewAnswer">查看答题内容</el-button>
      </div>
    </div>
    <answer-box :resourceCaseId="resourceCaseId" :answerItem="answerItem" v-if="isShowAnswer" @handleEmit="isShowAnswer=false"/>
  </div>
</template>

<script>
import { trainingInteraction, showScore, groupScoreDetail } from '@/api/teacher/manage/trainingInteractionManage'
import answerBox from './interactionAnswerBox'
export default {
  name: 'interactionComment',
  data () {
    return {
      resourceCaseId: this.$route.query.id,
      caseNodeId: this.$route.query.caseNodeId,
      caseNodeName: this.$route.query.caseNodeName,
      stuGroupId: this.$route.query.stuGroupId,
      cases: {
        nodeNum: '',
        resourceCaseId: '',
        resourceCaseName: '',
        resourceGroupName: '',
        caseRequestCn: '',
        caseRequestEn: '',
        resourceCaseBgList: [],
        finishedFlag: '',
        lessonICaseId: '',
        classNames: '',
        currentCaseNodeName: '',
        isGroup: '',
        stuNo: ''
      },
      scores: {
        resourceCaseName: '',
        resourceCaseBgList: [],
        caseGroupId: '',
        caseGroupName: '',
        caseNodeId: '',
        caseNodeName: '',
        groupIndex: [],
        lessonICaseId: '',
        resourceCaseId: '',
        score: '',
        stuAnswerId: '',
        stuGroupId: '',
        stuGroupName: ''
      },
      scoreDetail: [],
      isShowAnswer: false,
      answerItem: []
    }
  },
  components: {
    answerBox
  },
  mounted () {
    this.trainingInteraction()
  },
  methods: {
    async trainingInteraction () {
      const res = await trainingInteraction({ resourceCaseId: this.resourceCaseId })
      if (res.code === '200') {
        this.cases = res.data
        this.showScore()
      } else {
        this.$message.error(res.message)
      }
    },
    async showScore () {
      const res = await showScore({
        caseNodeId: this.caseNodeId,
        caseNodeName: this.caseNodeName,
        lessonICaseId: this.cases.lessonICaseId,
        resourceCaseId: this.resourceCaseId,
        stuGroupId: this.stuGroupId
      })
      if (res.code === '200') {
        this.scores = res.data
        if (this.scores.groupIndex.length > 0) {
          this.groupScoreDetail(this.scores.groupIndex[0].caseScoreId)
        }
      } else {
        this.$message.error(res.message)
      }
    },
    async groupScoreDetail (caseScoreId) {
      const res = await groupScoreDetail({ caseScoreId })
      if (res.code === '200') {
        this.scoreDetail = JSON.parse(res.data.scoreDetail)
      } else {
        this.$message.error(res.message)
      }
    },
    // 查看答题内容
    viewAnswer () {
      this.isShowAnswer = true
      this.answerItem = {
        caseGroupId: this.scores.caseGroupId,
        stuAnswerId: this.scores.stuAnswerId
      }
    }
  }
}
</script>
<style scoped lang="scss" rel="stylesheet/scss">
  .interaction-start {
    .container {
      display: flex;
      justify-content: space-between;
      .box-left {
        width: 550px;
        background: #fff;
        padding: 15px;
        .section {
          .sm-group{
            margin-top: 10px;
          }
          .train-info {
            color: #BBBBBB;
            font-size: 14px;
            margin-top: 10px;
          }
          .content {
            color: #BBBBBB;
            font-size: 14px;
            padding:20px 0;
            line-height: 1.2;
          }
          .card {
            border-radius: 20px;
            background: #f5f5f5;
            width: 455px;
            margin: 0 auto;
            .row {
              display: flex;
              align-items: center;
              justify-content: space-between;
            }
            .row-1{
              padding: 0 20px;
              line-height: 60px;
              border-bottom: 1px solid #D2D2D2;
            }
            .row-2{
              padding: 0 60px;
              line-height: 50px;
            }
          }
          .list-box {
            margin-top: 20px;
            ul {
              li {
                line-height: 60px;
                font-size: 14px;
                border-bottom: 1px solid #f5f5f5;
                padding: 0 10px;
                position: relative;
                i{
                  margin-left: 10px;
                }
                &:hover {
                  background: #f5f5f5;
                }
                &.cursor {
                  cursor: pointer;
                }
                .right-arrow {
                  position: absolute;
                  right: 10px;
                }
              }
            }
          }
        }
      }
      .box-right {
        width: 630px;
        min-height: 100%;
        background: #fff;
        padding: 15px;
        box-sizing: border-box;
        .title {
          font-size: 14px;
          font-weight: bold;
          position: relative;
          display: flex;
          align-items: center;
          justify-content: space-between;
          .tab {
            display: flex;
            .tab-item {
              width: 85px;
              line-height: 40px;
              border: 1px solid #D9D9D9;
              text-align: center;
              font-weight: initial;
              cursor: pointer;
              &.active {
                border: 1px solid #828282;
              }
            }
          }
          .time {
            font-size: 14px;
            color: #828282;
            position: absolute;
            right: 0;
            font-weight: normal;
          }
        }
        .content {
          color:#BBBBBB;
          font-size: 14px;
          padding:20px 0;
          line-height: 1.2;
        }
        .media-box {
          padding: 15px 0;
          .video {
            width: 100%;
          }
        }
        .file-box {
          line-height: 40px;
          display: flex;
          justify-content: space-between;
          border-bottom: 1px solid #f5f5f5;
          font-size: 14px;
          font-weight: bold;
          a {
            color: #009cf6;
            font-weight: normal;
          }
        }
        .fill-box {
          .fill-title {
            font-size: 14px;
          }
          textarea {
            width: 100%;
            margin-top: 20px;
          }
        }
        .report-box {
          li {
            line-height: 70px;
            position: relative;
            .right-arrow {
              position: absolute;
              right: 0;
            }
            textarea {
              width: 100%;
              margin-top: 20px;
            }
          }
        }
        .wait-btn, .submit-btn {
          width: 100%;
          line-height: 40px;
          border-radius: 10px;
          background: #BBBBBB;
          color: #fff;
          text-align: center;
          margin-top: 30px;
          cursor: pointer;
        }
      }
    }
  }
  .score-box{
    display: flex;
    justify-content: space-between;
    align-items: center;
    line-height: 50px;
    padding: 10px;
    font-size: 14px;
  }
  .inter-btn{
    width: 100%;
  }
</style>
